<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>ec: ec::Loop Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">ec
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>ec</b></li><li class="navelem"><a class="el" href="classec_1_1Loop.html">Loop</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="classec_1_1Loop-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">ec::Loop Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>事件主循环类，一个线程只能有一个Loop对象。  
 <a href="classec_1_1Loop.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="loop_8h_source.html">loop.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for ec::Loop:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classec_1_1Loop.png" usemap="#ec::Loop_map" alt=""/>
  <map id="ec::Loop_map" name="ec::Loop_map">
<area href="classec_1_1TcpServerDispatcher.html" title="TCP服务器会话调度管理器 " alt="ec::TcpServerDispatcher" shape="rect" coords="0,56,153,80"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:ac861df4ad2e7779e31932b2171935f81"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81">Event</a> { <b>kEventStart</b> = 0, 
<a class="el" href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81ae18354c950ca663c8eeb805eb0635ce7">kEventRun</a>, 
<a class="el" href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81af538557b2dd5e6dd576a16a8b510f9d8">kEventEnd</a>, 
<a class="el" href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81a4ce3e65585742fda1ced3e6ba87bb80c">kEventMax</a>
 }</td></tr>
<tr class="memdesc:ac861df4ad2e7779e31932b2171935f81"><td class="mdescLeft">&#160;</td><td class="mdescRight">Loop内部事件枚举  <a href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81">More...</a><br/></td></tr>
<tr class="separator:ac861df4ad2e7779e31932b2171935f81"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7c68e22f03ea2b4b670a440291438aed"><td class="memItemLeft" align="right" valign="top">typedef std::function&lt; bool(<a class="el" href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81">ec::Loop::Event</a> <br class="typebreak"/>
event)&gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a7c68e22f03ea2b4b670a440291438aed">EventHandler</a></td></tr>
<tr class="memdesc:a7c68e22f03ea2b4b670a440291438aed"><td class="mdescLeft">&#160;</td><td class="mdescRight">事件处理函数  <a href="#a7c68e22f03ea2b4b670a440291438aed">More...</a><br/></td></tr>
<tr class="separator:a7c68e22f03ea2b4b670a440291438aed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaa0d9bf951a410663fc354e5be062229"><td class="memItemLeft" align="right" valign="top">typedef std::function&lt; void(uint64_t <br class="typebreak"/>
frame)&gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#aaa0d9bf951a410663fc354e5be062229">FrameHandler</a></td></tr>
<tr class="memdesc:aaa0d9bf951a410663fc354e5be062229"><td class="mdescLeft">&#160;</td><td class="mdescRight">每幀处理函数  <a href="#aaa0d9bf951a410663fc354e5be062229">More...</a><br/></td></tr>
<tr class="separator:aaa0d9bf951a410663fc354e5be062229"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ab104699b3b40815f32e5272e85fb01d7"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab104699b3b40815f32e5272e85fb01d7"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#ab104699b3b40815f32e5272e85fb01d7">operator event_base *</a> () const </td></tr>
<tr class="memdesc:ab104699b3b40815f32e5272e85fb01d7"><td class="mdescLeft">&#160;</td><td class="mdescRight">转换为event_base *指针 <br/></td></tr>
<tr class="separator:ab104699b3b40815f32e5272e85fb01d7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af4830e98d557cb3be841f8aa3e9c588b"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af4830e98d557cb3be841f8aa3e9c588b"></a>
event_base *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#af4830e98d557cb3be841f8aa3e9c588b">getBase</a> () const </td></tr>
<tr class="memdesc:af4830e98d557cb3be841f8aa3e9c588b"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取event_base *指针 <br/></td></tr>
<tr class="separator:af4830e98d557cb3be841f8aa3e9c588b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a57deb8ad44ad522dc64f37e6ceef6595"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a57deb8ad44ad522dc64f37e6ceef6595"></a>
uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a57deb8ad44ad522dc64f37e6ceef6595">getId</a> () const </td></tr>
<tr class="memdesc:a57deb8ad44ad522dc64f37e6ceef6595"><td class="mdescLeft">&#160;</td><td class="mdescRight">获得自动生成的Id号 <br/></td></tr>
<tr class="separator:a57deb8ad44ad522dc64f37e6ceef6595"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adc30b5686fd9fb9b820868af4ffea513"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adc30b5686fd9fb9b820868af4ffea513"></a>
uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#adc30b5686fd9fb9b820868af4ffea513">getFrameRound</a> () const </td></tr>
<tr class="memdesc:adc30b5686fd9fb9b820868af4ffea513"><td class="mdescLeft">&#160;</td><td class="mdescRight">获得经过的幀数 <br/></td></tr>
<tr class="separator:adc30b5686fd9fb9b820868af4ffea513"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a134b0eb8eaa83270eb375df11160bea5"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a134b0eb8eaa83270eb375df11160bea5"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a134b0eb8eaa83270eb375df11160bea5">isThread</a> () const </td></tr>
<tr class="memdesc:a134b0eb8eaa83270eb375df11160bea5"><td class="mdescLeft">&#160;</td><td class="mdescRight">是否是以新线程在运行 <br/></td></tr>
<tr class="separator:a134b0eb8eaa83270eb375df11160bea5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aede057b26d3c5a5c54dabb953bb9945b"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#aede057b26d3c5a5c54dabb953bb9945b">start</a> ()</td></tr>
<tr class="memdesc:aede057b26d3c5a5c54dabb953bb9945b"><td class="mdescLeft">&#160;</td><td class="mdescRight">在当前线程运行事件循环  <a href="#aede057b26d3c5a5c54dabb953bb9945b">More...</a><br/></td></tr>
<tr class="separator:aede057b26d3c5a5c54dabb953bb9945b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa673dc1821347b95f0c1fddb78db41e2"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#aa673dc1821347b95f0c1fddb78db41e2">startThread</a> ()</td></tr>
<tr class="memdesc:aa673dc1821347b95f0c1fddb78db41e2"><td class="mdescLeft">&#160;</td><td class="mdescRight">启动新线程运行事件循环  <a href="#aa673dc1821347b95f0c1fddb78db41e2">More...</a><br/></td></tr>
<tr class="separator:aa673dc1821347b95f0c1fddb78db41e2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a452a6746df86ca3f9e32cbbba8896968"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a452a6746df86ca3f9e32cbbba8896968">waitThread</a> ()</td></tr>
<tr class="memdesc:a452a6746df86ca3f9e32cbbba8896968"><td class="mdescLeft">&#160;</td><td class="mdescRight">等待线程结束，与startThread配合使用  <a href="#a452a6746df86ca3f9e32cbbba8896968">More...</a><br/></td></tr>
<tr class="separator:a452a6746df86ca3f9e32cbbba8896968"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9c8926512c35227aa01d1a23cec1fcdf"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a9c8926512c35227aa01d1a23cec1fcdf">stop</a> (bool pending=true)</td></tr>
<tr class="memdesc:a9c8926512c35227aa01d1a23cec1fcdf"><td class="mdescLeft">&#160;</td><td class="mdescRight">停止事件循环  <a href="#a9c8926512c35227aa01d1a23cec1fcdf">More...</a><br/></td></tr>
<tr class="separator:a9c8926512c35227aa01d1a23cec1fcdf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9e0c3dfd61a2a909644654bb7fc452b9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a9e0c3dfd61a2a909644654bb7fc452b9">async</a> (ec::Command cmd, uint8_t *data, uint16_t dataSize, ec::AsyncHandler handler)</td></tr>
<tr class="memdesc:a9e0c3dfd61a2a909644654bb7fc452b9"><td class="mdescLeft">&#160;</td><td class="mdescRight">异步调用命令  <a href="#a9e0c3dfd61a2a909644654bb7fc452b9">More...</a><br/></td></tr>
<tr class="separator:a9e0c3dfd61a2a909644654bb7fc452b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac817156aaff57dcb5068c4ca20536c5c"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ac817156aaff57dcb5068c4ca20536c5c"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#ac817156aaff57dcb5068c4ca20536c5c">async</a> (ec::Command cmd, T &amp;value, ec::AsyncHandler handler)</td></tr>
<tr class="memdesc:ac817156aaff57dcb5068c4ca20536c5c"><td class="mdescLeft">&#160;</td><td class="mdescRight">异步调用命令  <a href="#ac817156aaff57dcb5068c4ca20536c5c">More...</a><br/></td></tr>
<tr class="separator:ac817156aaff57dcb5068c4ca20536c5c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4f34cbbabe5c798b725a61670dd9d6a7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a4f34cbbabe5c798b725a61670dd9d6a7">post</a> (uint8_t *data, uint16_t dataSize)</td></tr>
<tr class="memdesc:a4f34cbbabe5c798b725a61670dd9d6a7"><td class="mdescLeft">&#160;</td><td class="mdescRight">异步发送数据  <a href="#a4f34cbbabe5c798b725a61670dd9d6a7">More...</a><br/></td></tr>
<tr class="separator:a4f34cbbabe5c798b725a61670dd9d6a7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab120f6b96e2dd165a353e4c2d767dc6c"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ab120f6b96e2dd165a353e4c2d767dc6c"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#ab120f6b96e2dd165a353e4c2d767dc6c">post</a> (T value)</td></tr>
<tr class="memdesc:ab120f6b96e2dd165a353e4c2d767dc6c"><td class="mdescLeft">&#160;</td><td class="mdescRight">异步发送数据  <a href="#ab120f6b96e2dd165a353e4c2d767dc6c">More...</a><br/></td></tr>
<tr class="separator:ab120f6b96e2dd165a353e4c2d767dc6c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a54c8e94f74760c38d0c07c2c7584a1d4"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a54c8e94f74760c38d0c07c2c7584a1d4"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a54c8e94f74760c38d0c07c2c7584a1d4">regAsyncHandler</a> (ec::Command cmd, ec::AsyncHandler handler)</td></tr>
<tr class="memdesc:a54c8e94f74760c38d0c07c2c7584a1d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">注册async回调，没有注册回调的异步调用将通过onAsync处理 <br/></td></tr>
<tr class="separator:a54c8e94f74760c38d0c07c2c7584a1d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa815829ba034e87209d62958d94c1bf9"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa815829ba034e87209d62958d94c1bf9"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#aa815829ba034e87209d62958d94c1bf9">regPostHandler</a> (ec::PostHandler handler)</td></tr>
<tr class="memdesc:aa815829ba034e87209d62958d94c1bf9"><td class="mdescLeft">&#160;</td><td class="mdescRight">注册post回调，不注册将通过onPost处理 <br/></td></tr>
<tr class="separator:aa815829ba034e87209d62958d94c1bf9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9106028b7c268472a27832fe7812ba7f"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9106028b7c268472a27832fe7812ba7f"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a9106028b7c268472a27832fe7812ba7f">regEventHandler</a> (<a class="el" href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81">ec::Loop::Event</a> event, <a class="el" href="classec_1_1Loop.html#a7c68e22f03ea2b4b670a440291438aed">ec::Loop::EventHandler</a> handler)</td></tr>
<tr class="memdesc:a9106028b7c268472a27832fe7812ba7f"><td class="mdescLeft">&#160;</td><td class="mdescRight">注册内部事件回调，没有注册回调的事件将通过onEvent处理 <br/></td></tr>
<tr class="separator:a9106028b7c268472a27832fe7812ba7f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6ad6f4a613cad7f4090c98bb370edac7"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6ad6f4a613cad7f4090c98bb370edac7"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a6ad6f4a613cad7f4090c98bb370edac7">regFrameHandler</a> (<a class="el" href="classec_1_1Loop.html#aaa0d9bf951a410663fc354e5be062229">ec::Loop::FrameHandler</a> handler)</td></tr>
<tr class="memdesc:a6ad6f4a613cad7f4090c98bb370edac7"><td class="mdescLeft">&#160;</td><td class="mdescRight">注册每幀回调，不注册将通过onFrame处理 <br/></td></tr>
<tr class="separator:a6ad6f4a613cad7f4090c98bb370edac7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:abb797bdabdefdff5b6cc3f2b1b249747"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classec_1_1Loop.html">Loop</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#abb797bdabdefdff5b6cc3f2b1b249747">curLoop</a> ()</td></tr>
<tr class="memdesc:abb797bdabdefdff5b6cc3f2b1b249747"><td class="mdescLeft">&#160;</td><td class="mdescRight">返回当前线程的Loop  <a href="#abb797bdabdefdff5b6cc3f2b1b249747">More...</a><br/></td></tr>
<tr class="separator:abb797bdabdefdff5b6cc3f2b1b249747"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a459fada2bbc382637fab88b3ce914d46"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classec_1_1Loop.html">Loop</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a459fada2bbc382637fab88b3ce914d46">get</a> (uint32_t id)</td></tr>
<tr class="memdesc:a459fada2bbc382637fab88b3ce914d46"><td class="mdescLeft">&#160;</td><td class="mdescRight">根据id查找Loop  <a href="#a459fada2bbc382637fab88b3ce914d46">More...</a><br/></td></tr>
<tr class="separator:a459fada2bbc382637fab88b3ce914d46"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a2a40b87b2fa1cbb820692c8a10bed3ab"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2a40b87b2fa1cbb820692c8a10bed3ab"></a>
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a2a40b87b2fa1cbb820692c8a10bed3ab">onAsync</a> (ec::Command cmd, const <a class="el" href="classec_1_1Data.html">ec::Data</a> &amp;request, <a class="el" href="classec_1_1Data.html">ec::Data</a> &amp;response)</td></tr>
<tr class="memdesc:a2a40b87b2fa1cbb820692c8a10bed3ab"><td class="mdescLeft">&#160;</td><td class="mdescRight">继承此接口处理异步命令调用 <br/></td></tr>
<tr class="separator:a2a40b87b2fa1cbb820692c8a10bed3ab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3365009f41dd34e57c261485f0eb49cd"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3365009f41dd34e57c261485f0eb49cd"></a>
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a3365009f41dd34e57c261485f0eb49cd">onPost</a> (<a class="el" href="classec_1_1Data.html">ec::Data</a> &amp;data)</td></tr>
<tr class="memdesc:a3365009f41dd34e57c261485f0eb49cd"><td class="mdescLeft">&#160;</td><td class="mdescRight">继承此接口处理异步数据 <br/></td></tr>
<tr class="separator:a3365009f41dd34e57c261485f0eb49cd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a739a3679b5ca8d66dca537cb1df9c5c0"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a739a3679b5ca8d66dca537cb1df9c5c0"></a>
virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a739a3679b5ca8d66dca537cb1df9c5c0">onEvent</a> (<a class="el" href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81">ec::Loop::Event</a> event)</td></tr>
<tr class="memdesc:a739a3679b5ca8d66dca537cb1df9c5c0"><td class="mdescLeft">&#160;</td><td class="mdescRight">继承此接口处理内部事件 <br/></td></tr>
<tr class="separator:a739a3679b5ca8d66dca537cb1df9c5c0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4b904f427bf6568f216692997bd17e15"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4b904f427bf6568f216692997bd17e15"></a>
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1Loop.html#a4b904f427bf6568f216692997bd17e15">onFrame</a> (uint64_t round)</td></tr>
<tr class="memdesc:a4b904f427bf6568f216692997bd17e15"><td class="mdescLeft">&#160;</td><td class="mdescRight">继承此接口处理每幀逻辑 <br/></td></tr>
<tr class="separator:a4b904f427bf6568f216692997bd17e15"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>事件主循环类，一个线程只能有一个Loop对象。 </p>
<p>封装了libevent的struct event_base时间循环机制；</p>
<p>内部以5毫秒每幀的频率处理异步请求 </p>
</div><h2 class="groupheader">Member Typedef Documentation</h2>
<a class="anchor" id="a7c68e22f03ea2b4b670a440291438aed"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef std::function&lt;bool (<a class="el" href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81">ec::Loop::Event</a> event)&gt; <a class="el" href="classec_1_1Loop.html#a7c68e22f03ea2b4b670a440291438aed">ec::Loop::EventHandler</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>事件处理函数 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">event</td><td>Loop内部事件 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>返回错误码，0表示正确 </dd></dl>

</div>
</div>
<a class="anchor" id="aaa0d9bf951a410663fc354e5be062229"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef std::function&lt;void (uint64_t frame)&gt; <a class="el" href="classec_1_1Loop.html#aaa0d9bf951a410663fc354e5be062229">ec::Loop::FrameHandler</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>每幀处理函数 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">frame</td><td>当前幀号 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Enumeration Documentation</h2>
<a class="anchor" id="ac861df4ad2e7779e31932b2171935f81"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="classec_1_1Loop.html#ac861df4ad2e7779e31932b2171935f81">ec::Loop::Event</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Loop内部事件枚举 </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="ac861df4ad2e7779e31932b2171935f81ae18354c950ca663c8eeb805eb0635ce7"></a>kEventRun</em>&#160;</td><td class="fielddoc">
<p>启动前将触发此事件 </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ac861df4ad2e7779e31932b2171935f81af538557b2dd5e6dd576a16a8b510f9d8"></a>kEventEnd</em>&#160;</td><td class="fielddoc">
<p>事件循环开始前将触发此事件 </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="ac861df4ad2e7779e31932b2171935f81a4ce3e65585742fda1ced3e6ba87bb80c"></a>kEventMax</em>&#160;</td><td class="fielddoc">
<p>事件循环结束后将触发此事件 </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a9e0c3dfd61a2a909644654bb7fc452b9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ec::Loop::async </td>
          <td>(</td>
          <td class="paramtype">ec::Command&#160;</td>
          <td class="paramname"><em>cmd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>dataSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">ec::AsyncHandler&#160;</td>
          <td class="paramname"><em>handler</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>异步调用命令 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">cmd</td><td>命令码 </td></tr>
    <tr><td class="paramname">data</td><td>数据块地址 </td></tr>
    <tr><td class="paramname">dataSize</td><td>数据块大小 </td></tr>
    <tr><td class="paramname">handler</td><td>命令回调函数 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See Also</dt><dd>ec::AsyncHandler </dd></dl>

</div>
</div>
<a class="anchor" id="ac817156aaff57dcb5068c4ca20536c5c"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void ec::Loop::async </td>
          <td>(</td>
          <td class="paramtype">ec::Command&#160;</td>
          <td class="paramname"><em>cmd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">T &amp;&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">ec::AsyncHandler&#160;</td>
          <td class="paramname"><em>handler</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>异步调用命令 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">cmd</td><td>命令码 </td></tr>
    <tr><td class="paramname">value</td><td>数据 </td></tr>
    <tr><td class="paramname">handler</td><td>命令回调函数 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See Also</dt><dd>AsyncHandler </dd></dl>

</div>
</div>
<a class="anchor" id="abb797bdabdefdff5b6cc3f2b1b249747"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classec_1_1Loop.html">Loop</a> * ec::Loop::curLoop </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>返回当前线程的Loop </p>
<dl class="section return"><dt>Returns</dt><dd>当前线程Loop指针，没有Loop则NULL </dd></dl>

</div>
</div>
<a class="anchor" id="a459fada2bbc382637fab88b3ce914d46"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classec_1_1Loop.html">Loop</a> * ec::Loop::get </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>根据id查找Loop </p>
<dl class="section return"><dt>Returns</dt><dd>Loop指针 </dd></dl>

</div>
</div>
<a class="anchor" id="a4f34cbbabe5c798b725a61670dd9d6a7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ec::Loop::post </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>dataSize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>异步发送数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">value</td><td>数据 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ab120f6b96e2dd165a353e4c2d767dc6c"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void ec::Loop::post </td>
          <td>(</td>
          <td class="paramtype">T&#160;</td>
          <td class="paramname"><em>value</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>异步发送数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>数据块地址 </td></tr>
    <tr><td class="paramname">dataSize</td><td>数据块大小 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aede057b26d3c5a5c54dabb953bb9945b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ec::Loop::start </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>在当前线程运行事件循环 </p>
<p>运行成功后会阻塞知道停止 </p>
<dl class="section return"><dt>Returns</dt><dd>是否成功 </dd></dl>

</div>
</div>
<a class="anchor" id="aa673dc1821347b95f0c1fddb78db41e2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ec::Loop::startThread </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>启动新线程运行事件循环 </p>
<dl class="section return"><dt>Returns</dt><dd>是否成功 </dd></dl>

</div>
</div>
<a class="anchor" id="a9c8926512c35227aa01d1a23cec1fcdf"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ec::Loop::stop </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>pending</em> = <code>true</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>停止事件循环 </p>
<p>如果以新线程运行的，则会停止新线程。 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pending</td><td>是否等待事件结束才停止 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a452a6746df86ca3f9e32cbbba8896968"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ec::Loop::waitThread </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>等待线程结束，与startThread配合使用 </p>
<dl class="section see"><dt>See Also</dt><dd>bool <a class="el" href="classec_1_1Loop.html#aa673dc1821347b95f0c1fddb78db41e2" title="启动新线程运行事件循环 ">Loop::startThread()</a> </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>include/ec/<a class="el" href="loop_8h_source.html">loop.h</a></li>
<li>src/loop.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Jul 3 2015 02:15:14 for ec by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>
